package com.eiletxie.springcloud.service;

import com.netflix.discovery.converters.jackson.EurekaXmlJacksonCodec;
import org.springframework.stereotype.Component;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @Author EiletXie
 * @Since 2020/3/11 22:40
 */
@Component
public class PaymentFallbackService implements PaymentHystrixService {

    @Override
    public String paymentInfo_OK(Integer id) {
        return "----PaymentFallbackService fall back paymentInfo_OK,o(╥﹏╥)o";
    }

    @Override
    public String paymentInfo_Timeout(Integer id) {
        return "----PaymentFallbackService fall back paymentInfo_Timeout,o(╥﹏╥)o";
    }

    public static void main(String[] args) throws Exception {
        AtomicLong circuitOpenedOrLastTestedTime=new AtomicLong();
        long l = System.currentTimeMillis();
        circuitOpenedOrLastTestedTime.set(l);
        System.out.println(l);
        Thread.sleep(3*1000);
        long timeCircuitOpenedOrWasLastTested = circuitOpenedOrLastTestedTime.get();
        long lb = System.currentTimeMillis();
        System.out.println(lb);
        System.out.println(circuitOpenedOrLastTestedTime.compareAndSet(timeCircuitOpenedOrWasLastTested,lb));
    }
}
